﻿<?php
defined('BASEPATH') or die ('No direct script access allowed');

class tasks_model extends Model{
    
    protected $_data=null;
    protected $_tid=null;
    
    function tasks_model(){
        parent::Model();
    }
    
    function get_tasks_by_id($id){
        if($id){
        	$query="select * from doi_task where id=".intval($id);
        	$this->_data=$this->db->query($query);
        	$this->_data=$this->_data->result();
        }else{
            show_error('ID');
        }
        return $this->_data;
    }
    
    function get_all_tasks(){
        if(!$this->_data){
        	$query="select * from doi_task";
        	$this->_data=$this->db->query($query);
        	$this->_data=$this->_data->result();
        }
        return $this->_data;
    }
    
    function get_tasks_by_tag(){
        
    }
    
    function _build_query(){
        
    }
    
    function _build_where(){
        
    }
    
    function _build_orderby(){
        
    }
    
    function get_tasks_by_sid($sid){
        if(!$sid){
        	$query="select * from doi_task where sid=".intval($sid);
        	$this->_data=$this->db->query($query);
        	$this->_data=$this->_data->result();
        }else{
        	show_error("SID");
        }
        return $this->_data;
    }
    
    function get_tasks_by_cid($cid){
        if(!$cid){
        	$query="select * from doi_task where cid=".intval($cid);
        	$this->_data=$this->db->query($query);
        	$this->_data=$this->_data->result();
        }else{
        	show_error("CID");
        }
        return $this->_data;
    }
    
    
}